package tm;

import java.sql.Connection;

/**
 * 线程所属的数据库链接Connection
 * @author wsz
 * @date 2021/10/13 11:23
 **/
public class ConnectionUtils {

    private ThreadLocal<Connection> threadLocal = new ThreadLocal<>();

    public Connection getConnection() {
        Connection connection = threadLocal.get();
        if (connection == null) {
            connection = DruidUtils.getInstance().getConnection();
            threadLocal.set(connection);
        }
        return connection;
    }
}
